<?php
require_once WEB_MODEL_DIR . DIRECTORY_SEPARATOR . 'DAO' . DIRECTORY_SEPARATOR . 'GamePromotionDAO.php';

class GamePromotionService {

    public function getGamePromotion($context, $result) {
        $gamePromotionArr = null;
        try {
            $gamePromotionDAO = new GamePromotionDAO($context);

            $gamePromotionArr = $gamePromotionDAO -> getGamePromotion();
            if (isset($gamePromotionArr) && !empty($gamePromotionArr)) {
                $result -> setSuccess();
            } else {
                $result -> setFailed("ERR01", "No Game Promotion");
                $context -> logError("ERR01", "No Game Promotion Call By " . __METHOD__ . " ON " . __CLASS__);
            }
        } catch (Exception $e) {
            $result -> setException($e);
            $context -> logException($e);
        }

        return $gamePromotionArr;
    }

    public function getGameGuide($context, $result) {
        $gamePromotionArr = null;
        try {
            $gamePromotionDAO = new GamePromotionDAO($context);

            $gamePromotionArr = $gamePromotionDAO -> getGameGuide();
            if (isset($gamePromotionArr) && !empty($gamePromotionArr)) {
                $result -> setSuccess();
            } else {
                $result -> setFailed("ERR01", "No Game Promotion");
                $context -> logError("ERR01", "No Game Guide Call By " . __METHOD__ . " ON " . __CLASS__);
            }
        } catch (Exception $e) {
            $result -> setException($e);
            $context -> logException($e);
        }

        return $gamePromotionArr;
    }

    public function getGamePromotionById($context, $result, $id) {
        $gamePromotionArr = null;
        try {
            $gamePromotionDAO = new GamePromotionDAO($context);

            $gamePromotionArr = $gamePromotionDAO -> getGamePromotionById($id);
            if (isset($gamePromotionArr) && !empty($gamePromotionArr)) {
                $result -> setSuccess();
            } else {
                $result -> setFailed("ERR01", "No Game Promotion");
                $context -> logError("ERR01", "No Game Guide Call By " . __METHOD__ . " ON " . __CLASS__);
            }
        } catch (Exception $e) {
            $result -> setException($e);
            $context -> logException($e);
        }

        return $gamePromotionArr;
    }

    public function getTelcoPromotion($context, $result) {
        $telcoPromotionArr = null;
        try {
            $gamePromotionDAO = new GamePromotionDAO($context);

            $telcoPromotionArr = $gamePromotionDAO -> getTelcoPromotion();
            if (isset($telcoPromotionArr) && !empty($telcoPromotionArr)) {
                $result -> setSuccess();
            } else {
                $result -> setFailed("ERR01", "No Game Promotion");
                $context -> logError("ERR01", "No Game Guide Call By " . __METHOD__ . " ON " . __CLASS__);
            }
        } catch (Exception $e) {
            $result -> setException($e);
            $context -> logException($e);
        }

        return $telcoPromotionArr;
    }
}
?>